package me.itsoo.artemis.framework.repository.datasource;

import me.itsoo.artemis.framework.repository.config.SqlConfigurable;

import javax.sql.DataSource;
import java.io.PrintWriter;
import java.util.logging.Logger;

/**
 * ConnectionPool
 *
 * @author zxy
 * @version 0.0.1
 * @since 2023/5/18
 */
public interface ConnectionPool extends DataSource, SqlConfigurable {

    /**
     * 获取连接
     *
     * @param autoCommit boolean
     * @return Connection
     */
    SqlConnection getConnection(boolean autoCommit);

    /**
     * 释放连接
     *
     * @param conn Connection
     */
    void releaseConnection(SqlConnection conn);

    /**
     * 是否为活动连接
     *
     * @param conn SqlConnection
     * @return boolean
     */
    boolean isActiveConnection(SqlConnection conn);


    @Override
    default <T> T unwrap(Class<T> iface) {
        throw new UnsupportedOperationException("Oops...");
    }

    @Override
    default boolean isWrapperFor(Class<?> iface) {
        throw new UnsupportedOperationException("Oops...");
    }

    @Override
    default PrintWriter getLogWriter() {
        throw new UnsupportedOperationException("Oops...");
    }

    @Override
    default void setLogWriter(PrintWriter out) {
        throw new UnsupportedOperationException("Oops...");
    }

    @Override
    default void setLoginTimeout(int seconds) {
        throw new UnsupportedOperationException("Oops...");
    }

    @Override
    default int getLoginTimeout() {
        throw new UnsupportedOperationException("Oops...");
    }

    @Override
    default Logger getParentLogger() {
        throw new UnsupportedOperationException("Oops...");
    }
}
